import {
  request,
  requestPayment,
  upload,
  filesUpload
} from './http'

import Config from './config.js'

let BaseUrl = Config.baseUrl

class Api {

  /**
   * @desc 获取OpenId
   */
  getOpenId(params) {
    return request(BaseUrl.baseApi + '/getOpenId', params, true)
  }

  /**
   * @desc 授权登录
   */
  authorize(params) {
    return request(BaseUrl.baseApi + '/login/authorize', params, true)
  }


  /**
   * @desc 首页-banner
   */
  getRecommend(params, showLoading = true) {
    return request(BaseUrl.baseApi + '/getRecommend', params, showLoading)
  }

  /**
   * @desc 首页-为你推荐列表
   */
  getProducts(params, showLoading = true) {
    return request(BaseUrl.baseApi + '/queryProducts', params, showLoading)
  }
  /**
   * @desc 分类列表
   */
  getCategory(params, showLoading = true) {
    return request(BaseUrl.baseApi + '/queryCategory', params, showLoading)
  }

  /**
   * @desc 商品详情
   */
  getProduct(params, showLoading = true) {
    return request(BaseUrl.baseApi + '/getProduct', params, showLoading)
  }

  /**
   * @desc 创建订单
   */
  createOrder(params, showLoading = true) {
    return request(BaseUrl.baseApi + '/createOrder', params, showLoading)
  }

  /**
   * @desc 获取用户信息
   */
  getUserInfo(params, showLoading = true) {
    return request(BaseUrl.baseApi + '/getUserInfo', params, showLoading)
  }

  /**
   * @desc 更新用户信息
   */
  updateUserInfo(params, showLoading = true) {
    return request(BaseUrl.baseApi + '/updateUserInfo', params, showLoading)
  }


  /**
   * @desc 订单列表
   */
  getOrders(params, showLoading = true) {
    return request(BaseUrl.baseApi + '/getOrders', params, showLoading)
  }
  /**
   * @desc 订单详情
   */
  getOrderById(params, showLoading = true) {
    return request(BaseUrl.baseApi + '/getOrderById', params, showLoading)
  }



}

const api = new Api()

export default api